<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <title>json example</title>

    <!--<link type="text/css" rel="stylesheet" href="css/main.css">-->

</head>
<body>

<script>

    // create playlist
    var createPlayList = function(id, data) {
        var plDiv = document.createElement('div');
        plDiv.setAttribute('id', "pl-" + id);

        if (data) {
            plDiv.innerHTML = data;
        } else {
            plDiv.innerHTML = "nothing";
        }

        document.body.appendChild(plDiv);
    }

    // convert duration
    var convertDuration = function(duration) {
        return Math.round((duration/1000/60)*100)/100;
    }


    // http://music.yandex.ru/get/playlist2.xml?kinds=2
    var pl = {"playlists":[{"kind":2,"revision":51,"title":"Мой плейлист","visibility":"default","tracks":["488996","488995","488994","488993","267869","2786101","354086","25588","25583","39894","286213","286208","286211","2782420","2782426","2782423","2749756","2782419","2782417","2782414","2782418","2782415","2782416","2782421","2782425","2782422","2782424","2822768","2222803","3918284","3918285","3918283","3918287","3918281","3918286","3918288","3918290","3918282","3918289","812338","812331","812329","812337","812334","812331","812338","812330","812333","812328","812336","812332","812335","2761942","360670","20778","89964","89957","89963","89951","4201","89945","89955","89953","89947","89959","89943","89949","4372044","2786094","2786097","29393","5657495"]}],"tracks":[{"id":"488996","storage_dir":"367c9e78.488996","duration":"316960","title":"Splitting The Atom","artist":"Massive Attack","artist_id":"12662","artist_var":"false","album":"Heligoland","album_id":"55505","cover":"http:\/\/storage.music.yandex.ru\/get\/2ac7ca0e.a.55505\/1.30x30.jpg"},{"id":"488995","storage_dir":"23c728ee.488995","duration":"404680","title":"Pray For Rain","artist":"Massive Attack","artist_id":"12662","artist_var":"false","album":"Heligoland","album_id":"55505","cover":"http:\/\/storage.music.yandex.ru\/get\/2ac7ca0e.a.55505\/1.30x30.jpg"},{"id":"488994","storage_dir":"8513d7b4.488994","duration":"403125","title":"Bulletproof Love","artist":"Massive Attack","artist_id":"12662","artist_var":"false","album":"Splitting The Atom","album_id":"51798","cover":"http:\/\/storage.music.yandex.ru\/get\/5f154765.a.51798\/1.30x30.jpg"},{"id":"488993","storage_dir":"5f9afeaf.488993","duration":"226353","title":"Psyche (Flash Treatment)","artist":"Massive Attack","artist_id":"12662","artist_var":"false","album":"Splitting The Atom","album_id":"51798","cover":"http:\/\/storage.music.yandex.ru\/get\/5f154765.a.51798\/1.30x30.jpg"},{"id":"267869","storage_dir":"bef4745e.267869","duration":"314073","title":"Karmacoma","artist":"Massive Attack","artist_id":"12662","artist_var":"false","album":"Collected","album_id":"27333","cover":"http:\/\/storage.music.yandex.ru\/get\/000177db.a.27333\/1.30x30.jpg"},{"id":"2786101","storage_dir":"d1a054ee.2786101","duration":"326400","title":"Virus","artist":"Bjork","artist_id":"7276","artist_var":"false","album":"Biophilia","album_id":"299045","cover":"http:\/\/storage.music.yandex.ru\/get\/0ac84ceb.a.299045\/1.30x30.jpg"},{"id":"354086","storage_dir":"02c88376.354086","duration":"366970","title":"Dissolved Girl","artist":"Massive Attack","artist_id":"12662","artist_var":"false","album":"Mezzanine","album_id":"35627","cover":"http:\/\/storage.music.yandex.ru\/get\/b060361b.a.35627\/1.30x30.jpg"},{"id":"25588","storage_dir":"eb0b6c23.25588","duration":"322019","title":"Hyperballad","artist":"Bjork","artist_id":"7276","artist_var":"false","album":"Greatest Hits","album_id":"2166","cover":"http:\/\/storage.music.yandex.ru\/get\/11ef0f54.a.2166\/1.30x30.jpg"},{"id":"25583","storage_dir":"0682ece0.25583","duration":"346835","title":"Isobel","artist":"Bjork","artist_id":"7276","artist_var":"false","album":"Greatest Hits","album_id":"2166","cover":"http:\/\/storage.music.yandex.ru\/get\/11ef0f54.a.2166\/1.30x30.jpg"},{"id":"39894","storage_dir":"29587f02.39894","duration":"334296","title":"I Miss You (Dobie Rub Part One","artist":"Bjork","artist_id":"7276","artist_var":"false","album":"Telegram","album_id":"3303","cover":"http:\/\/storage.music.yandex.ru\/get\/299172d3.a.3303\/1.30x30.jpg"},{"id":"286213","storage_dir":"c3611185.286213","duration":"335833","title":"Make Me Bad \/ In Between Days (Feat. The Cure)","artist":"Korn","artist_id":"89882","artist_var":"false","album":"MTV Unplugged","album_id":"29000","cover":"http:\/\/storage.music.yandex.ru\/get\/e8c37ea0.a.29000\/1.30x30.jpg"},{"id":"286208","storage_dir":"dbe86d3a.286208","duration":"231107","title":"Creep","artist":"Korn","artist_id":"89882","artist_var":"false","album":"MTV Unplugged","album_id":"29000","cover":"http:\/\/storage.music.yandex.ru\/get\/e8c37ea0.a.29000\/1.30x30.jpg"},{"id":"286211","storage_dir":"64876636.286211","duration":"235888","title":"Freak On A Leash (Feat. Amy Lee)","artist":"Korn","artist_id":"89882","artist_var":"false","album":"MTV Unplugged","album_id":"29000","cover":"http:\/\/storage.music.yandex.ru\/get\/e8c37ea0.a.29000\/1.30x30.jpg"},{"id":"2782420","storage_dir":"fc69fb17.2782420","duration":"176640","title":"It's Anybody's Spring","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782426","storage_dir":"9442421c.2782426","duration":"200881","title":"Music Is Better Than Words","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782423","storage_dir":"0ea54d39.2782423","duration":"240710","title":"Anytime, Anywhere","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2749756","storage_dir":"bb67a2c3.2749756","duration":"157440","title":"The Night They Invented Champagne","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782419","storage_dir":"64748b6a.2782419","duration":"266501","title":"Two Sleepy People","artist":"Norah Jones","artist_id":"593","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782417","storage_dir":"2244cbb4.2782417","duration":"143568","title":"You're The Cream In My Coffee","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782414","storage_dir":"0f39f221.2782414","duration":"256130","title":"Something Good","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782418","storage_dir":"7dd8496e.2782418","duration":"192339","title":"Nine O'Clock","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782415","storage_dir":"c7fb7830.2782415","duration":"232254","title":"Love Won't Let You Get Away","artist":"Sara Bareilles","artist_id":"42234","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782416","storage_dir":"294945b3.2782416","duration":"305580","title":"It's Easy To Remember","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782421","storage_dir":"9aab126e.2782421","duration":"175986","title":"The Sadder But Wiser Girl","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782425","storage_dir":"59fc2123.2782425","duration":"328071","title":"Laura","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782422","storage_dir":"0bd35342.2782422","duration":"221988","title":"You And I","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2782424","storage_dir":"a583aca0.2782424","duration":"179853","title":"She's Wonderful Too","artist":"Seth MacFarlane","artist_id":"538874","artist_var":"false","album":"Music Is Better Than Words","album_id":"298621","cover":"http:\/\/storage.music.yandex.ru\/get\/445f1f30.a.298621\/1.30x30.jpg"},{"id":"2822768","storage_dir":"e31491e0.2822768","duration":"162220","title":"Up All Night","artist":"Alex Clare","artist_id":"431624","artist_var":"false","album":"The Lateness Of The Hour","album_id":"440668","cover":"http:\/\/storage.music.yandex.ru\/get\/b74e65a6.a.440668\/1.30x30.jpg"},{"id":"2222803","storage_dir":"e661a011.2222803","duration":"218640","title":"Treading Water","artist":"Alex Clare","artist_id":"431624","artist_var":"false","album":"The Lateness Of The Hour","album_id":"440668","cover":"http:\/\/storage.music.yandex.ru\/get\/b74e65a6.a.440668\/1.30x30.jpg"},{"id":"3918284","storage_dir":"6b119921.3918284","duration":"212065","title":"Relax My Beloved","artist":"Alex Clare","artist_id":"431624","artist_var":"false","album":"The Lateness Of The Hour","album_id":"440668","cover":"http:\/\/storage.music.yandex.ru\/get\/b74e65a6.a.440668\/1.30x30.jpg"}]};


    for(i = 0; i < pl.tracks.length; i++) {
        //console.log(i + ". " + pl.tracks[i].artist + " - " + pl.tracks[i].title + " (" + Math.round((pl.tracks[i].duration/1000/60)*100)/100+ ")");
        createPlayList(i, i+1 + ". " + pl.tracks[i].artist + " - " + pl.tracks[i].title + " (" + convertDuration(pl.tracks[i].duration) + ")");
    }


</script>
</body>
</html>